﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace DotNetExtensions.Core.Restful
{
    public class PageResult<T>
    {
        public PageResult() { }

        public PageResult(int pageSize)
        {
            PageSize = pageSize;
        }
        public PageResult(int pageSize, long total)
        {
            PageSize = pageSize;
            Total = total;
        }
        public long Total { get; set; }

        private int pages = 0;
        public int Pages
        {
            get
            {
                if (PageSize > 0 && Total > 0) return (int)((Total - 1) / PageSize) + 1;
                return pages;
            }
        }

        public int PageSize { get; set; }
        public int PageIndex { get; set; }

        public bool IsEmpty { get { return (Data == null ? false : false == Data.Any()); } }

        public IEnumerable<T> Data { get; set; }
    }
}
